package com.aiti.ai.config;


import dev.langchain4j.community.model.zhipu.ZhipuAiChatModel;
import dev.langchain4j.model.chat.ChatLanguageModel;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


import java.time.Duration;


@Configuration
public class ZhiPuModelConfiguration {

    @Value("${model.zhipu-api-key}")
    private String zhipuApiKey;


    @Bean
    ChatLanguageModel azureOpenAIChatLanguageModel() {
        ChatLanguageModel model = ZhipuAiChatModel.builder()
                .apiKey(zhipuApiKey)
                .callTimeout(Duration.ofSeconds(60))
                .connectTimeout(Duration.ofSeconds(60))
                .writeTimeout(Duration.ofSeconds(60))
                .readTimeout(Duration.ofSeconds(60))
                .temperature(0.0)
                .model("GLM-4-Flash")
                .maxToken(10240)
                .build();
        return model;
    }
}
